package com.cupk.common.base.utils.result;

/**
 * 响应结果生成工具
 * @author tjy
 */
public class ResultGenerator {
    private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";

    public static Result genSuccessResult() {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMsg(DEFAULT_SUCCESS_MESSAGE);
    }

    public static Result genSuccessResult(Object data) {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMsg("")
                .setData(data);
    }

    public static Result genSuccessResult(Object data,String msg) {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMsg(msg)
                .setData(data);
    }
    
    public static Result genSuccessResultPage(Object data,long count) {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMsg("查询成功")
                .setCount(count)
                .setData(data);
    }

    public static Result genFailResult(String message) {
        return new Result()
                .setCode(ResultCode.FAIL)
                .setMsg(message);
    }

    public static Result genFailResult(Object data,String message) {
        return new Result()
                .setCode(ResultCode.FAIL)
                .setMsg(message)
                .setData(data);
    }

}
